//
//  ZH_CommentsTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/26.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_CommentsTableViewCell.h"
@interface ZH_CommentsTableViewCell()
@property (nonatomic,weak)UIImageView *photoImage;
@property (nonatomic,weak)UILabel *timeLabel;
@property (nonatomic,weak)UILabel *nameLabel;
@property (nonatomic,weak)UILabel *contentLabel;
@property (nonatomic,weak)UIButton *praiseButton;
@end
@implementation ZH_CommentsTableViewCell

///创建
+ (instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_EvaluationInforTableViewCell";
    ZH_CommentsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_CommentsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}

///初始化
-(void)initDefault
{
    [self unShowClickEffect];
    self.bottomLongLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.photoImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(11));
        make.left.equalTo(self.contentView).offset(FITSCALE(22));
        make.width.mas_equalTo(FITSCALE(37));
        make.height.mas_equalTo(FITSCALE(37));
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.photoImage);
        make.left.equalTo(self.photoImage.mas_right).offset(FITSCALE(6));
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(FITSCALE(7));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
        make.top.equalTo(self.timeLabel.mas_bottom).offset(FITSCALE(15));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-10));
    }];
    [self.praiseButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(14));
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
    }];
}
#pragma mark - getter,setter
- (UIImageView *)photoImage{
    if (!_photoImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@""];
        image.backgroundColor = kFontColorRed;
        image.layer.cornerRadius = FITSCALE(18);
        image.layer.masksToBounds = YES;
        image.clipsToBounds = YES;
        [self.contentView addSubview:_photoImage = image];
    }
    return _photoImage;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        UILabel *label = [UILabel createLabelWithText:@"TT" font:kFontSize_24];
        [self.contentView addSubview:_nameLabel = label];
    }
    return _nameLabel;
}
- (UILabel *)timeLabel{
    if (!_timeLabel) {
        UILabel *label = [UILabel createLabelWithText:@"1小时前" font:kFontSize_22];
        label.textColor = [UIColor colorWithHexString:@"#999999"];
        [self.contentView addSubview:_timeLabel = label];
    }
    return _timeLabel;
}
- (UILabel *)contentLabel{
    if (!_contentLabel) {
        UILabel *label = [UILabel createLabelWithText:@"回复TT：感谢购买!" font:kFontSize_26];
        [label lableAutoLinefeed];
        [self.contentView addSubview:_contentLabel = label];
    }
    return _contentLabel;
}
- (UIButton *)praiseButton{
    if (!_praiseButton) {
        UIButton *button = [UIButton createButtonWithTitle:@"" normalImage:@"icon_good" pressImage:@"icon_good_selected" target:self action:nil];
        [self.contentView addSubview:_praiseButton = button];
    }
    return _praiseButton;
}
@end
